package server.universe;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Collection;

import javax.vecmath.Vector3d;

import server.object.AObject3D;
import server.object.AObject3DImpl;
import server.object.CObject3D;
import server.object.CObject3DImpl;
import server.universe.AUniverse;
import server.universe.AUniverseImpl;

public class UniverseFacade extends UnicastRemoteObject implements UniverseFacadeRemote {
	
	private static final long serialVersionUID = 5882323766310301863L;
	
	private AUniverse universe;
	
	public UniverseFacade() throws RemoteException {
		super();
		universe = new AUniverseImpl();
		Collection<CObject3D> objects = new ArrayList<CObject3D>();
		AObject3D object1 = new AObject3DImpl();
		object1.setName("carremulticolor");
		object1.setGeometry("Cone");
		object1.setPosition(new Vector3d(10, 20, 30));
		CObject3D cObject1 =new CObject3DImpl(object1);
		AObject3D object2 = new AObject3DImpl();
		object2.setName("losangeblanc");
		object2.setGeometry("Cone");
		CObject3D cObject2 =new CObject3DImpl(object2);
		objects.add(cObject1);
		objects.add(cObject2);
		universe.setObjects(objects);
	}

	@Override
	public Collection<String> getAllObjects() throws RemoteException{
		Collection<CObject3D> objects = universe.getAllObjects();
		Collection<String> objectsNames = new ArrayList<String>();
		for(CObject3D obj : objects){
			objectsNames.add(obj.getName());
		}
		System.out.println("objects récupérés : "+objectsNames);
		return objectsNames;
	}
	

}
